#include "Browserrr.h"
#include "NavigationController.h"

Browserrr::Browserrr(QWidget *parent)
    : QWidget(parent), ui(new Ui::Browserrr)
{
    ui->setupUi(this);
    view = new QWebEngineView(this);
    QStackedLayout *layout = new QStackedLayout(ui->frame);
    ui->frame->setLayout(layout);
    layout->addWidget(view);
    QString fst = "https://";
    ui->adress->setText(fst);
}
Browserrr::~Browserrr()
{
    delete ui;
    // 设置背景图片
    // setStyleSheet("background-image: url('D://qt6/qt6 data/Browser/background.jpeg'); background-repeat: no-repeat; background-position: center;");
}

void Browserrr::on_goBt_clicked()
{
    QString url = ui->adress->text();

    if (!url.isEmpty())
    {
        view->load(QUrl(url));
    }
}

void Browserrr::on_refreshBt_clicked()
{
    view->reload();
}

void Browserrr::on_adress_returnPressed()
{
    QString url = ui->adress->text();

    if (!url.isEmpty())
    {
        view->load(QUrl(url));
    }
}

void Browserrr::on_homeBt_clicked()
{
    MyNavigationController::instance().backToMainPage();
}
